package cs2340.klondike.TaskFudger;

import java.util.ArrayList;
import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

/**
 * This is a helper class to display strings onto the screen when the user taps on the pinpoint
 */
public class HelloItemizedOverlay extends ItemizedOverlay<OverlayItem>
{
	 private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
	 private Context mContext;
	
	 /**
	 * This is a constructor for this class with Drawable and context as it's parameters.
	 * @param defaultMarker
	 * @param context
	 */
	public HelloItemizedOverlay(Drawable defaultMarker, Context context)
	 {
		 super(boundCenterBottom(defaultMarker));
		 mContext = context;
	 }
	
	 /**
	 * This is another constructor for this class that takes in an overlayItem as it's parameter 
	 * @param overlay
	 */
	public void addOverlay(OverlayItem overlay)
	 {
		 mOverlays.add(overlay);
		 populate();
	 }
	 /* (non-Javadoc)
	 * @see com.google.android.maps.ItemizedOverlay#createItem(int)
	 */
	@Override
	 protected OverlayItem createItem(int i)
	 {
		 return mOverlays.get(i);
	 }
	 /* (non-Javadoc)
	 * @see com.google.android.maps.ItemizedOverlay#size()
	 */
	@Override
	 public int size()
	 {
		 return mOverlays.size();
	 }
	 /* (non-Javadoc)
	 * @see com.google.android.maps.ItemizedOverlay#onTap(int)
	 */
	@Override
	 protected boolean onTap(int index)
	 {
		 OverlayItem item = mOverlays.get(index);
		 AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
		 dialog.setTitle(item.getTitle());
		 dialog.setMessage(item.getSnippet());
		 dialog.show();
		 return true;
	 }
}